package com.itcast.mybatis.service;

import com.itcast.mybatis.mapper.CourseBaseMapper;
import com.itcast.mybatis.model.CourseBase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class CourseBaseServiceImpl implements CourseBaseService {

    @Autowired
    private CourseBaseMapper courseBaseMapper;

    @Override
    public boolean saveCourseBaseByTrans() {
        CourseBase courseBase1 = new CourseBase();
        courseBase1.setId("1111");
        courseBase1.setName("这是插入的第一条数据");

        courseBase1.setGrade("grade test");
        courseBase1.setMt("11111");
        courseBase1.setStudymodel("studymodel test");
        courseBase1.setSt("st test");
        courseBase1.setStatus("status test");
//        return courseBaseMapper.insert(courseBase1)>0;
        courseBaseMapper.insert(courseBase1);
        int x = 2/0;
        CourseBase courseBase2 = new CourseBase();
        courseBase2.setId("22222");
        courseBase2.setName("这是插入的第二条数据");
        courseBase2.setMt("11111");
        courseBase2.setStudymodel("studymodel test");
        courseBase2.setSt("st test");
        courseBase2.setStatus("status test");
        courseBaseMapper.insert(courseBase2);



        return true;
    }
}
